package com.way.filemanager.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RadioButton;

import hwdroid.widget.item.Item;
import hwdroid.widget.item.WidgetText2Item;
import hwdroid.widget.itemview.WidgetText2ItemView;



public class CustomWidgetText2ItemView extends WidgetText2ItemView {

    public CustomWidgetText2ItemView(Context context) {
        super(context);
        // TODO 自动生成的构造函数存根
    }
    public CustomWidgetText2ItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    /*

    public void setObject(Item object) {
        final WidgetText2Item item = (WidgetText2Item) object;

        if (item.leftviewgroup == null) {
            mLeftWidgetFrame.setVisibility(View.GONE);
        } else {
            mLeftWidgetFrame.setVisibility(View.VISIBLE);

            // ensure this view just could be added only once
            LinearLayout parent = (LinearLayout) item.leftviewgroup.getTag(R.id.hw_widget_text2_item_view_tag_key);
            if(parent != null) {
                parent.removeAllViews();
                parent.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                item.leftviewgroup.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
            }

            // before add new view, we should confirm disconnect between the old child view
            // avoid the old child view get layout view by getTag() and then clear new child view
            LinearLayout child = (LinearLayout) mLeftWidgetFrame.getTag(R.id.hw_widget_text2_item_view_tag_key);
            if(child != null) {
                mLeftWidgetFrame.removeAllViews();
                mLeftWidgetFrame.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                child.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
            }


            if(null == item.leftviewgroup.getTag(R.id.hw_widget_text2_item_view_tag_key))
                mLeftWidgetFrame.addView(item.leftviewgroup);

            // setup new connection between layout and child view
            item.leftviewgroup.setTag(R.id.hw_widget_text2_item_view_tag_key, mLeftWidgetFrame);
            mLeftWidgetFrame.setTag(R.id.hw_widget_text2_item_view_tag_key, item.leftviewgroup);
        }
        mRightWidgetFrame.removeAllViews();
        switch(item.getTypeMode()) {
            case CHECK_MODE:
                if(mCheckBox == null) {
                    mCheckBox = new CheckBox(this.getContext());
                    mCheckBox.setClickable(false);
                    mCheckBox.setFocusable(false);

                }
                mRightWidgetFrame.setVisibility(View.VISIBLE);
                mCheckBox.setEnabled(object.isEnabled());
                mRightWidgetFrame.addView(mCheckBox);
                setCheckBoxChecked(item.isChecked());
                break;
            case RADIO_MODE:
                if(mRadioButton == null) {
                    mRadioButton = new RadioButton(this.getContext());
                    mRadioButton.setClickable(false);
                    mRadioButton.setFocusable(false);
                }
                mRightWidgetFrame.setVisibility(View.VISIBLE);
                mRadioButton.setEnabled(object.isEnabled());
                mRightWidgetFrame.addView(mRadioButton);
                setRadioButtonChecked(item.isChecked());
                break;
            case IMAGE_MODE:
            case NORMAL_MODE:
                {
                    if (item.rightviewgroup == null) {
                        mRightWidgetFrame.setVisibility(View.GONE);
                    } else {
                        mRightWidgetFrame.setVisibility(View.VISIBLE);

                        // refer to the leftviewgroup
                        LinearLayout parent = (LinearLayout) item.rightviewgroup
                                .getTag(R.id.hw_widget_text2_item_view_tag_key);
                        if (parent != null) {
                            parent.removeAllViews();
                            parent.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                            item.rightviewgroup.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                        }

                        LinearLayout child = (LinearLayout) mRightWidgetFrame
                                .getTag(R.id.hw_widget_text2_item_view_tag_key);
                        if (child != null) {
                            mRightWidgetFrame.removeAllViews();
                            mRightWidgetFrame.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                            child.setTag(R.id.hw_widget_text2_item_view_tag_key, null);
                        }

                        if (null == item.rightviewgroup.getTag(R.id.hw_widget_text2_item_view_tag_key))
                            mRightWidgetFrame.addView(item.rightviewgroup);

                        item.rightviewgroup.setTag(R.id.hw_widget_text2_item_view_tag_key,
                                mRightWidgetFrame);
                        mRightWidgetFrame.setTag(R.id.hw_widget_text2_item_view_tag_key,
                                item.rightviewgroup);
                    }
                }
                break;
            default:
                mRightWidgetFrame.setVisibility(View.GONE);
                break;
            }

        mTextView.setEnabled(object.isEnabled());
        mSubTextView.setEnabled(object.isEnabled());

        setTextView(item.mText);
        setSubtextView(item.mSubText);

    }*/
}
